<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/axios.min.js"></script>
    <script>

        function addUser() {
            //表单对象
            var formObj = new FormData();
            formObj.append("name",$("userName").value);
            formObj.append("birthday",$("birthday").value);
            formObj.append("myFile",$("myFile").files[0]);

            //设置请求头
            let config = {
                headers: {'Content-Type': 'multipart/form-data' }
            }

            axios.post("/upload/add",formObj,config).then(resp =>{
                if (resp.data == "ok"){
                    location.href = "/html/index.html";
                }
            })
        }

        function $(id) {
            return document.getElementById(id);
        }
    </script>
</head>
<body>
用户名：<input type="text" id="userName"><br>
生日：<input type="text" id="birthday"><br>
头像：<input type="file" id="myFile"><br>
<input type="button" value="提交" onclick="addUser()">
</body>
</html>